package com.Maykk.Demo06;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * @ClassName: Demo02
 * @Description: TODO calendar 练习
 * @Author: MaykkStar@163.com
 */
public class Demo02 {
    public static void main(String[] args) {
        Calendar cal = Calendar.getInstance();
        int year = cal.get(Calendar.YEAR);
        int month = cal.get(Calendar.MONTH);
        int date = cal.get(Calendar.DATE);
        System.out.println(year + "," + (month + 1) + "," + date);

        cal.set(2023, 9, 2);
        int year_set = cal.get(Calendar.YEAR);
        int month_set = cal.get(Calendar.MONTH);
        int date_set = cal.get(Calendar.DATE);
        System.out.printf("%d年%d月%d日\n", year_set, month_set, date_set);

        Date date1 = new Date(year_set, month_set, date_set);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        System.out.println(sdf.format(date1));


    }
}
